<#include "common/baseMarco.ftl">
<@header title="发布需求">
<link rel="stylesheet" href="/css/common.css">
<style>
    .container {
        background: #ffffff;
    }

    form {
        margin-top: 30px;
        margin-left: 20px;
        margin-right: 20px;
        background: #f6f6f6;
        border: 1px solid #cccccc;
        border-radius: 5px;
        overflow: hidden;
    }

    .weui-msg {
        border-bottom: 1px dotted #cccccc;
    }

    .weui-icon-info {
        color: #2694e9;
        font-size: 44px;
    }

    .container .weui-msg__desc {
        font-size: 16px;
        color: #999999;
    }

    .weui-cells {
        background: #f6f6f6;
        margin-top: 0px;
        font-size: 12.5px;
        color: #999999;
    }
    .weui-cells:before{
        border: none;
    }
    .weui-cells:after{
        border: none;
    }
    .weui-cells .weui-cell {
        background: #ffffff;
        margin-top: 11px;
        margin-left: 10px;
        margin-right: 10px;
        border-radius: 5px;
    }
    .weui-cells .weui-cell .weui-label{
        width: auto;
        margin-right: 5px;
    }
    .weui-btn_area {
        background: #2694e9;
        margin-top: 15px;
    }

    .weui-btn_area .weui-btn_primary {
        background: #2694e9;
        font-size: 18px;
        color: #ffffff;
    }
    .weui-btn_primary:not(.weui-btn_disabled):active{
        background-color: #2694e9;
    }
    .weui-msg__title{
        margin-left: 10px;
        margin-top: 28px;
        font-size: 12px;
        color: #999999;
    }
    .weui-btn:after{
        border: none;
    }
    .weui-cell_primary{
        flex: 1;
    }
    .weui-cell:before {
        border: none;
    }
</style>
</@header>
<div class="container">
    <form action="" method="post" id="form">
        <input type="hidden" name="requireId" value="${requireId!''}">
        <div class="weui-msg">
            <div class="weui-msg__icon-area">
                <i class="weui-icon-info weui-icon_msg"></i>
            </div>
            <div class="weui-msg__text-area">
                <p class="weui-msg__desc">
                    请留下您的联系方式
                </p>
            </div>
        </div>
        <div class="weui-cells">
            <div class="weui-cell cell">
                <div class="weui-cell_hd">
                    <label class="weui-label">姓名&nbsp;:</label>
                </div>
                <div class="weui-cell_bd weui-cell_primary">
                    <input class="weui-input" id="realname" name="realname" type="text" placeholder=""/>
                </div>
            </div>
            <div class="weui-cell cell">
                <div class="weui-cell_hd">
                    <label class="weui-label">电话&nbsp;:</label>
                </div>
                <div class="weui-cell_bd weui-cell_primary">
                    <input class="weui-input" id="mobile" name="mobile" type="tel" placeholder=""/>
                </div>
            </div>
            <div class="weui-cell cell">
                <div class="weui-cell_hd">
                    <label class="weui-label">邮箱&nbsp;:</label>
                </div>
                <div class="weui-cell_bd weui-cell_primary">
                    <input class="weui-input" id="email" name="email" type="email" placeholder=""/>
                </div>
            </div>
        </div>
        <div class="weui-btn_area">
            <a class="weui-btn weui-btn_primary" id="button" href="javascript:">提交</a>
        </div>
    </form>
</div>
<@footer>
<script type="text/javascript">
        $(function () {

            var mailReg = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;

            var mobileReg =  /^1[3|4|5|7|8][0-9]{9}$/;

            var nameReg = /^[a-zA-Z\u4e00-\u9fa5]{2,20}$/;

            $('#button').on('click', function (e) {



                var form = $("#form").serialize();
                var arr = form.split(/&/gi);
                var params = {
                    'requireId':${requireId},
                    'realname':$("#realname").val(),
                    'mobile':$("#mobile").val(),
                    'email':$("#email").val()
                };

                if (!nameReg.test(params.realname)) {
                    if(!params.realname){
                        $.toptip('请输入姓名!',1000,'warning');
                    }else{
                        $.toptip('请输入正确的姓名!',1000,'warning');
                    }
                    return;
                }
                if(!mobileReg.test(params.mobile)){
                    if(!params.mobile){
                        $.toptip('请输入电话号码!',1000,'warning');
                    }else{
                        $.toptip('请输入正确的手机号码!',1000,'warning');
                    }
                    return;
                }
                if(!mailReg.test(params.email)){
                    if(!params.email){
                        $.toptip('请输入邮箱地址!',1000,'warning');
                    }else{
                        $.toptip('请输入正确邮箱地址!',1000,'warning');
                    }
                    return;
                }
                $.post('/require/bind/contact',params,function (data) {
                    window.location.href = "/result";
                });
            });
        })
</script>
</@footer>
